package com.atguigu.gulimall.cart.config;

import com.atguigu.gulimall.cart.interceptor.CartInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * 拦截器配置类
 */
@Configuration
public class GulimallWebConfig implements WebMvcConfigurer {
    /**
     * 添加拦截器的配置，不能只把拦截器加入容器中，不然拦截器不生效的
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //设置拦截的范围，"/**" 表示拦截所有请求
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");
    }}


